package com.jadefashion.quartz;

import com.jadefashion.health.resources.QiniuUtils;
import com.jadefashion.health.resources.RedisConstant;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import redis.clients.jedis.Jedis;
import redis.clients.jedis.JedisPool;

import java.util.Set;

@Component("myQuartz")
public class MyQuartz {
   @Autowired
    private JedisPool jedisPool;

   public void run(){
       Jedis jedis = jedisPool.getResource();
       Set<String> sdiff = jedis.sdiff(RedisConstant.SETMEAL_PIC_RESOURCES, RedisConstant.SETMEAL_PIC_DB_RESOURCES);
       if(sdiff.size()>0){
           for (String s : sdiff) {
               //删除七牛云的多余图片
               QiniuUtils.deleteFileFromQiniu(s);
           }
       }
       //删除redis存储的数据
       jedis.del(RedisConstant.SETMEAL_PIC_RESOURCES);
       jedis.del(RedisConstant.SETMEAL_PIC_DB_RESOURCES);
       jedis.close();
   }
}
